<!DOCTYPE html>
<html>
<head>
	<div th:include="base-libs-easyui :: base-libs-easyui" />
	<script th:src="@{/console/js/My97DatePicker/WdatePicker.js}"></script>
<title>机房信息</title>
<style type="text/css">
	body {
		padding: 0px 10px;
	}
	.form-table input{
		width: 230px;
		padding-left: 4px;
	}
	.form-table select{
		width: 235px!important;
	}
	.tree-icon{
		display: none;
	}

	.bt-selected{
		background-color: #D0E9C6;
	}
</style>
</head>
<script th:inline="javascript">
    /**读取request中的初始化数据*/
    var requestData = [[${requestData}]];
</script>
<script type="text/javascript">
	$(function() {
		initView();
        $(this).registerManagerPage();
        initData();
	});

	function initData() {
        var updatedSbxx = StoreCache.removeCache("curr_sbxx");
        if(updatedSbxx)
        {
            $("#formBqxx").data("updatedSbxx", updatedSbxx);
            setData();
        }else {
            var updatedjfxx = StoreCache.removeCache("curr_jfxx");
            setData(updatedjfxx);
		}
	}

	function setData(data){
	    var updatedSbxx  ;
	    if(data){
            updatedSbxx = data;
		}else{
            updatedSbxx =$("#formBqxx").data("updatedSbxx");
            updatedSbxx["GMRQ"] = updatedSbxx["GMRQ"].substring(0,7);
		}
        $(".form-control").each(function(){
            var name = $(this).attr("name");
            if(!StringUtils.isEmpty(name)){
                var value = updatedSbxx[name];
                $(this).QuickField("setData", value);
			}
        });
	}

	function initView() {
		$("#formBqxx").attr("action", contextRoot + "/yljgsb/saveSbxx");
		$("#btnSave").on("click", btnSaveHandler);
        $("#btnClose").on("click", btnCloseHandler);
	}

	function btnSaveHandler(){
        if($(".form-control").QuickValidate())
        {
            var method = "insert";
            var old = $("#formBqxx").data("updatedSbxx");
            if(old){
                method = "update";
			}
            var params = {type: method};
            $.QuickRemote.AjaxFiledFormSubmit("formBqxx", saveHandler, params);
        }
	}
	function saveHandler(result){
        var state = result["state"];
        if(state)
        {
            $.QuickAlert.alertNormal("保存成功", {callback: function(){
                $("#btnClose").trigger("click");
            }});
        }
        else
        {
            var info = result["info"];
            $.QuickAlert.alertFail({content: info["faultInfo"]});
        }
	}

	/**验证机构*/
	function validateJg(){
	    var PTJGID = $("input[name='PTJGID']").val();
        if(StringUtils.isEmpty(PTJGID)){
            return "请选择机构";
		}else{
            return "";
		}
	}

	/**返回按钮*/
	function btnCloseHandler() {
        parent.layer.closeAll();
	}
</script>

<body class="easyui-layout">
	<div region="center" style="border: none;">
		<form id="formBqxx">
			<table class="form-table">
				<tr>
					<td class="td-text">
						<label>设备代号</label>
					</td>
					<td class="td-content">
						<input id="SBBH" class="form-control" name="SBBH" placeholder="设备代号"
							   quick-config="label:'设备代号', validateProxy:'notNull length', length: '64'">
					</td>
				</tr>
				<tr>
					<td class="td-text">
						<label>设备名称</label>
					</td>
					<td class="td-content">
						<input id="SBMC" class="form-control" name="SBMC" placeholder="设备名称"
							   quick-config="label:'设备名称', validateProxy:'notNull length', length: '128'">
						<input id="JFID" name="JFID" type="text" hidden="hidden"
							   class="form-control">
						<input id="PTJGID" name="PTJGID" type="text" hidden="hidden"
							   class="form-control">
						<input id="SBID" name="SBID" type="text" hidden="hidden"
							   class="form-control">
					</td>
				</tr>
				<tr>
					<td class="td-text">
						<label>产地</label>
					</td>
					<td class="td-content">
						<select id="CD" name="CD" class="form-control"
								quick-config="label:'产地', validateProxy:'notNull'">
							<option value="">请选择</option>
							<option value="1">进口</option>
							<option value="2">国产/合资</option>
						</select>
					</td>
				</tr>
				<tr>
					<td class="td-text">
						<label>生成厂家</label>
					</td>
					<td class="td-content">
						<input id="SCCJ" name="SCCJ" type="text" placeholder="生成厂家"
							   quick-config="label:'生成厂家', validateProxy:'notNull length', length: '128'"
							   class="form-control">
					</td>
				</tr>
				<tr>
					<td class="td-text">
						<label>设备型号</label>
					</td>
					<td class="td-content">
						<input id="SBXH" name="SBXH" type="text" placeholder="设备型号"
							   quick-config="label:'设备型号', validateProxy:'notNull length', length: '64'"
							   class="form-control">
					</td>
				</tr>
				<tr>
					<td class="td-text">
						<label>购买日期</label>
					</td>
					<td class="td-content">
						<!--<input id="GMRQ" name="GMRQ" type="text" placeholder="购买日期"
							   quick-config="label:'购买日期', validateProxy:'notNull' "
							   class="form-control">-->
						<input id="GMRQ" readonly="readonly" class="form-control laydate-icon" name="GMRQ" onclick="WdatePicker({dateFmt:'yyyy-MM'})" style="width: 210px;height: 28px;"
							   quick-config="label:'购买日期', validateProxy:'notNull'"/>
					</td>
				</tr>
				<tr>
					<td class="td-text">
						<label>新旧情况</label>
					</td>
					<td class="td-content">
						<select id="XJQK" name="XJQK" type="text" placeholder="新旧情况"
							   quick-config="label:'新旧情况', validateProxy:'notNull' "
								class="form-control">
							<option value="">请选择</option>
							<option value="1">新设备</option>
							<option value="2">二手设备</option>
						</select>
					</td>
				</tr>
				<tr>
					<td class="td-text">
						<label>购买单价(千元)</label>
					</td>
					<td class="td-content">
						<input id="GMDJ" name="GMDJ" type="text" placeholder="购买单价(千元)"
							   quick-config="label:'购买单价(千元)', validateProxy:'notNull length num', length: '10'"
							   class="form-control">
					</td>
				</tr>
				<tr>
					<td class="td-text">
						<label>使用情况</label>
					</td>
					<td class="td-content">
						<select id="SYQK" name="SYQK" type="text" placeholder="使用情况"
								quick-config="label:'使用情况', validateProxy:'notNull' "
								class="form-control">
							<option value="">请选择</option>
							<option value="1">启用</option>
							<option value="2">未启用</option>
							<option value="3">报废</option>
						</select>
					</td>
				</tr>
			</table>
		</form>
	</div>
	<div region="south" style="height: 41px; padding-top: 6px;">
		<button id="btnClose" type="button" style="margin-right: 10px; float: right;">关闭</button>
		<button id="btnSave" type="button" style="margin-right: 10px; float: right;">保存</button>
	</div>
</body>
</html>


